package com.yanqu.road.server.cmd.beauty;

import com.yanqu.road.pb.beauty.BeautyProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.BeautyModule;
import com.yanqu.road.server.pb.BasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @Author wpj
 * @Date 2020/9/1
 */
@Cmd(code = GameProtocol.S_BEAUTY_PUT_ON_SKIN, desc = "美女穿皮肤")
public class BeautyPutOnSkinCmd extends AbstractCommand {

    int beautyId;
    int skinId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        BeautyProto.BeautyPutOnSkinReqMsg msg = BeautyProto.BeautyPutOnSkinReqMsg.parseFrom(packet.getBytes());
        beautyId = msg.getBeautyId();
        skinId = msg.getSkinId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(BeautyModule.class).putOnSkin(beautyId, skinId);
    }

    @Override
    public void sendData(GamePlayer player) {
        player.sendPacket(ClientProtocol.U_BEAUTY_PUT_ON_SKIN, BasePb.getBaseRetRespMsg(ret));
    }
}
